//
//  QingdanViewController.m
//  XDLookPic
//
//  Created by wanglong8889@126.com on 14-5-25.
//  Copyright (c) 2014年 XD-XY. All rights reserved.
//

#import "QingdanViewController.h"
#import "ShopListCell.h"
#import "UIImageView+WebCache.h"
//#import "goodDetailViewController.h"
#import "QingDanTableViewCell.h"
#import "ShopTrolley.h"
//#import "CommentGoodsViewController.h"

@interface QingdanViewController ()

@end

@implementation QingdanViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.titleLabel.text = @"商品清单";
    if (IOS7) {
        self.navigationBarBg.image = [UIImage imageNamed:@"redIOS7"];
    }else{
        self.navigationBarBg.image = [UIImage imageNamed:@"redIOS6"];
    }
    [self.leftBtn setBackgroundImage:[UIImage imageNamed:@"pd_25_bai"] forState:UIControlStateNormal];
    self.titleLabel.textColor = [UIColor whiteColor];
    myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, UI_MAINSCREEN_HEIGHT - UI_NAVIGATION_BAR_HEIGHT) style:UITableViewStylePlain];
    myTableView.delegate = self;
    myTableView.dataSource = self;
    myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.contentView addSubview:myTableView];

 
}




#pragma mark - TableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    ShopTrolley *shop;
    if ([_dataArray count] > 0) {
        shop = [_dataArray objectAtIndex:indexPath.row];
        if (shop.attrHeight == 0.0) {
            
            return 130;
        }
    }
    
    
    return 130+5+shop.attrHeight;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString * cellIde = @"listCell";
    QingDanTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIde];
    if (cell == nil) {
        cell = [[QingDanTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIde];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    cell.shopTrolley = [_dataArray objectAtIndex:indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
  
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
